flowbox: Avoid an assertion in snapshot()
authorMatthias Clasen <mclasen@redhat.com>
Thu, 14 May 2020 00:33:25 +0000 (20:33 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 14 May 2020 01:47:11 +0000 (21:47 -0400)
The api contract for size_allocate() vfuncs is
that they must allocate all the children that are
going to be snapshotted in snapshot(). The flowbox
size_allocate() was just bailing out when the children
request a size of 0x0, leading to an assertion in
snapshot() vfunc later. Just allocate all children
a size of 0x0 in this case.

gtk/gtkflowbox.c

index 5c022d45cd6f44913d36b32bbe040fa9213ae916..ddbf34fa33514133fa0a0253c21cd7c4af4b285e 100644 (file)
@@ -1561,7 +1561,28 @@ gtk_flow_box_size_allocate (GtkWidget *widget,
    */
   get_max_item_size (box, priv->orientation, &min_item_size, &nat_item_size);
   if (nat_item_size <= 0)
-    return;
+    {
+      child_allocation.x = 0;
+      child_allocation.y = 0;
+      child_allocation.width = 0;
+      child_allocation.height = 0;
+
+      for (iter = g_sequence_get_begin_iter (priv->children);
+           !g_sequence_iter_is_end (iter);
+           iter = g_sequence_iter_next (iter))
+        {
+          GtkWidget *child;
+
+          child = g_sequence_get (iter);
+
+          if (!child_is_visible (child))
+            continue;
+
+          gtk_widget_size_allocate (child, &child_allocation, -1);
+        }
+
+      return;
+    }
 
   /* By default flow at the natural item width */
   line_length = avail_size / (nat_item_size + item_spacing);